package com.gitee.feizns.itrip.personal.biz.controller;

import com.gitee.feizns.itrip.personal.beans.dto.Dto;
import com.gitee.feizns.itrip.personal.beans.pojo.User;
import com.gitee.feizns.itrip.personal.beans.vo.Page;
import com.gitee.feizns.itrip.personal.biz.entity.ao.ForAcceptAddHotelOrder;
import com.gitee.feizns.itrip.personal.biz.entity.ao.ForAcceptGetPersonalOrderList;
import com.gitee.feizns.itrip.personal.biz.entity.ao.ForAcceptPreOrderInfo;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewAddHotelOrder;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewGetPersonalOrderInfo;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewGetPersonalOrderRoomInfo;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewPersonalOrderList;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewPreOrderInfo;
import com.gitee.feizns.itrip.personal.biz.entity.vo.ForViewQueryOrderById;
import com.gitee.feizns.itrip.personal.biz.service.HotelOrderService;
import com.gitee.feizns.itrip.personal.utils.component.annotations.CurtUser;
import com.gitee.feizns.itrip.personal.utils.component.annotations.TokenValidate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author feizns
 * @since 2019/1/10 0010
 */
@TokenValidate
@RestController
@RequestMapping("/api/hotelorder")
public class HotelOrderController {

    @Autowired
    private HotelOrderService hotelOrderService;

    @PostMapping("/getpersonalorderlist")
    public Dto<Page<ForViewPersonalOrderList>> getPersonalOrderList(@RequestBody ForAcceptGetPersonalOrderList codition, @CurtUser User curtUser) {
        return Dto.getSuccessDto("获取个人订单列表成功", hotelOrderService.getPersonalOrderList(codition, curtUser.getId()));
    }
    
    @GetMapping("/getpersonalorderinfo/{orderId}")
    public Dto<ForViewGetPersonalOrderInfo> getPersonalOrderInfo(@PathVariable Long orderId) {
        return Dto.getSuccessDto("获取个人订单信息成功", hotelOrderService.getPersonalOrderInfo(orderId));
    }

    @GetMapping("/getpersonalorderroominfo/{orderId}")
    public Dto<ForViewGetPersonalOrderRoomInfo> getPersonalOrderRoomInfo(@PathVariable Long orderId) {
        return Dto.getSuccessDto("获取个人订单房型信息成功", hotelOrderService.getPersonalOrderRoomInfo(orderId));
    }

    @PostMapping("/getpreorderinfo")
    public Dto<ForViewPreOrderInfo> getPreOrderInfo(@RequestBody @Validated ForAcceptPreOrderInfo info) {
        return Dto.getSuccessDto("获取成功", hotelOrderService.getPreOrderInfo(info));
    }

    @GetMapping("/queryOrderById/{orderId}")
    public Dto<ForViewQueryOrderById> queryOrderById(@PathVariable Long orderId) {
        return Dto.getSuccessDto("获取订单成功", hotelOrderService.getOrderById(orderId));
    }

    @PostMapping("/addhotelorder")
    public Dto<ForViewAddHotelOrder> addHotelOrder(@RequestBody @Validated ForAcceptAddHotelOrder order, @CurtUser User curtUser) {
        return Dto.getSuccessDto("生成订单成功", hotelOrderService.addHotelOrder(order, curtUser.getId()));
    }
    
}
